package com.woman.beautylive.presentation.ui.main;

import android.app.Dialog;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;

import com.jakewharton.rxbinding.view.RxView;
import com.woman.beautylive.R;
import com.woman.beautylive.data.bean.AnchorSummary;
import com.woman.beautylive.domain.LocalDataManager;
import com.woman.beautylive.presentation.ui.base.BaseFragment;
import com.woman.beautylive.presentation.ui.chatting.DemoActivity;
import com.woman.beautylive.presentation.ui.main.find.PaiHangBangActivity;
import com.woman.beautylive.presentation.ui.main.find.PengYouQuanActivity;
import com.woman.beautylive.presentation.ui.main.index.CommendInterface;
import com.woman.beautylive.presentation.ui.main.index.CommendPresenter;
import com.woman.beautylive.util.Const;

import java.util.List;
import java.util.concurrent.TimeUnit;

import rx.functions.Action1;

/**
 * Created by dsawe on 2016/9/11.
 */
public class FindFragment extends BaseFragment{
    CommendPresenter commendPresenter;
    RelativeLayout re_pengyouquan,month_paihangbang;
    @Override
    protected int getLayoutId() {
        return R.layout.frag_main_find;
    }

    @Override
    protected void initViews(View view) {
        re_pengyouquan = $(view, R.id.re_pengyouquan);
        RxView.clicks($(view, R.id.re_pengyouquan)).throttleFirst(Const
                .VIEW_THROTTLE_TIME, TimeUnit.MILLISECONDS)
                .subscribe(new Action1<Void>() {
                    @Override
                    public void call(Void aVoid) {
                        startActivity(PengYouQuanActivity.createIntent(getActivity()));
                        getActivity().overridePendingTransition(R.anim.fragment_slide_right_in, R
                                .anim.fragment_slide_right_out);
                    }
                });
        month_paihangbang = $(view, R.id.month_paihangbang);
        RxView.clicks($(view, R.id.month_paihangbang)).throttleFirst(Const
                .VIEW_THROTTLE_TIME, TimeUnit.MILLISECONDS)
                .subscribe(new Action1<Void>() {
                    @Override
                    public void call(Void aVoid) {
                        startActivity(PaiHangBangActivity.createIntent(getActivity()));
                        getActivity().overridePendingTransition(R.anim.fragment_slide_right_in, R
                                .anim.fragment_slide_right_out);
                    }
                });
        commendPresenter = new CommendPresenter(new CommendInterface() {
            @Override
            public void showEmptyResult() {

            }

            @Override
            public void showData(List<AnchorSummary> list) {

            }

            @Override
            public void appendData(List<AnchorSummary> list) {
//                if (list.size()<5) {
//
//                }
            }

            @Override
            public void showNetworkException() {

            }

            @Override
            public void showUnknownException() {

            }

            @Override
            public void showDataException(String msg) {

            }

            @Override
            public void showLoadingComplete() {

            }

            @Override
            public Dialog showLoadingDialog() {
                return null;
            }

            @Override
            public void dismissLoadingDialog() {

            }

        });
        commendPresenter.loadCommendAnchors(LocalDataManager.getInstance().getLoginInfo().getToken(),LocalDataManager.getInstance().getLoginInfo().getCity());
    }

    public static FindFragment newInstance() {
        return new FindFragment();
    }

//    @Override
//    public void showData(List<AnchorSummary> list) {
//        List<AnchorSummary> arraylist=list;
//        Log.e("wsh",arraylist.size()+"");
//    }
//
//    @Override
//    public void showEmptyResult() {
//
//    }
//
//    @Override
//    public void appendData(List<AnchorSummary> list) {
//
//    }
}
